﻿using CustomItem.Interfaces;
using HarmonyLib;
using InventorySystem.Items.Firearms.Attachments;
using Mirror;

namespace CustomItem
{
    [HarmonyPatch]
    public static class Patches
    {
        [HarmonyPrefix]
        [HarmonyPatch(typeof(AttachmentsServerHandler), nameof(AttachmentsServerHandler.ServerReceiveChangeRequest))]
        public static bool ServerReceiveChangeRequest_Prefix(NetworkConnection conn, AttachmentsChangeRequest msg)
        {
            CustomItem pi = CustomItem.GetItem(msg.WeaponSerial);
            if (pi != null && pi is IWeaponItem iwi)
            {
                return iwi.CanModifyAttachments();
            }
            return true;
        }

        //public static bool Tubular_ServerTryReload_Prefix(TubularMagazineAmmoManager __instance, ref bool __result)
        //{
        //    return true;
        //}
        //public static bool ClipLoaded_ServerTryReload_Prefix(ClipLoadedInternalMagAmmoManager __instance, ref bool __result)
        //{
        //    return true;
        //}
        //public static bool Automatic_ServerTryReload_Prefix(AutomaticAmmoManager __instance, ref bool __result)
        //{
        //    return true;
        //}
        //public static bool Tubular_ServerTryUnload_Prefix(TubularMagazineAmmoManager __instance)
        //{
        //    return true;
        //}
        //public static bool ClipLoaded_ServerTryUnload_Prefix(ClipLoadedInternalMagAmmoManager __instance, ref bool __result)
        //{
        //    return true;
        //}
        //public static bool Automatic_ServerTryUnload_Prefix(AutomaticAmmoManager __instance, ref bool __result)
        //{
        //    return true;
        //}
    }
}